﻿using System;
using System.Data;

namespace CRS.Web.BaseData
{
    public partial class GoodsEdit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = -1;
            if (!IsPostBack)
            {
                BindData();
                InitData();
                Session["SelectGoods"] = null;
            }
        }

        private void BindData()
        {
            Type.Items.Add("烟类");
            Type.Items.Add("酒类");
            Type.Items.Add("茶类");
            Type.Items.Add("饮料类");

            Unit.Items.Add("支");
            Unit.Items.Add("瓶");
            Unit.Items.Add("条");
            Unit.Items.Add("斤");
            Unit.Items.Add("包");
        }

        private void InitData()
        {
            if(Session["SelectGoods"]!=null)
            {
                var selectInfo = (DataRow[])Session["SelectGoods"];
                BarCode.Text = selectInfo[0]["条码"].ToString();
                GoodsName.Text=selectInfo[0]["名称"].ToString();
                Qualification.Text = selectInfo[0]["规格"].ToString();
                Type.SelectedItem.Text=selectInfo[0]["类别"].ToString();
                InPrice.Text=selectInfo[0]["进价"].ToString();
                SalePrice.Text=selectInfo[0]["售价"].ToString();
                LowStock.Text = selectInfo[0]["最低库存"].ToString();
                Unit.SelectedItem.Text=selectInfo[0]["单位"].ToString();
                TextBox1.Text = selectInfo[0]["现有库存"].ToString();
            }
        }
    }
}
